package cn.itcast.bos.system.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import cn.itcast.bos.domain.security.Permission;

public interface PermissionDao extends JpaRepository<Permission, Integer>{

	@Query("from Permission p inner join fetch p.roles r "
			+ "inner join fetch r.users u where u.id=:id ")
	List<Permission> getPermissionByUserId(@Param("id")int id);

	@Query("from Permission p where p.id in :permissionIds")
	List<Permission> getPremissionByIds(@Param("permissionIds")
			Integer[] permissionIds);

}
